<?php

	// TITLE: Guest_list AUTO MODEL
	// FILE: scaffolding/model/guest_list.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createGuestList = function($con, $guestList) {
		$sql = 'INSERT INTO guest_list (event_id, guest_id, status) VALUES (';
		$sql .= $guest_list->getEventId() . ', ';
		$sql .= $guest_list->getGuestId() . ', ';
		$sql .= $guest_list->getStatus() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readGuestList = function($con, $id) {
		$sql = 'SELECT * FROM guest_list WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$guestList = new GuestList();
			$guestList->setEventId($dbio->select($readEvent(result[0])));
			$guestList->setGuestId($dbio->select($readGuest(result[1])));
			$guestList->setStatus(result[2]);
		} else {
			$guestList = false;
		}
		return $guestList;
	};

	$updateGuestList = function($con, $guestList) {
		$sql = 'UPDATE guest_list SET ';
		$sql .= 'event_id = ' . $guest_list->getEventId() . ', ';
		$sql .= 'guest_id = ' . $guest_list->getGuestId() . ', ';
		$sql .= 'status = ' . $guest_list->getStatus() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteGuestList = function($con, $id) {
		$sql = 'DELETE FROM guest_list WHERE event_id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listGuestList = function($con) {
		$sql = 'SELECT * FROM guest_list';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$guestLists = array();
			while ($result = mysqli_fetch_array($results)) {
				$guestList = new GuestList();
				$guestList->setEventId($dbio->select($readEvent(result[0])));
				$guestList->setGuestId($dbio->select($readGuest(result[1])));
				$guestList->setStatus(result[2]);
				$guestLists[] = guestList;
			}// end while
		} else {
			$guestLists = false;
		}
		return $guestLists;
	};

